package com.wx.wxpush.mapper;

import com.wx.wxpush.entiy.Cron;
import com.wx.wxpush.entiy.TempData;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;

@Component
public interface CornTaskMapper {
    @Insert("insert into cron (openid,cronmoring,cornnight) values (#{openid},#{cronMoring},#{cronNight})")
    int insertCron(String openid, String cronMoring, String cronNight);

    @Select("select openid from cron where openid =#{openid}")
    String  selectByOpenid(String openid);

    @Update("update  cron set cronmoring=#{cronMoring},cornnight=#{cronNight} where openid =#{openid}")
    int updateByOpenid(String openid, String cronMoring, String cronNight);

    @Select("select  cronmoring from cron")
    List<String>  selectList();

    @Select("select  cronmoring from cron")
    List<String> selectAllTask();
    @Select("select  cronmoring from cron")
    String selectAllTask1();

    @Select("select  cronmoring from cron")
    List<Cron> getAllScheduleTasks();
    @Select("select  *  from cron where cronmoring=#{crons}")
    List<Cron>  selectByCrons(String crons);
    @Select("select  * from cron where cornnight=#{crons}")
    List<Cron> selectByNightCrons(String crons);


    @Update("update cron set moringStatus=#{moringStatus} where openid=#{openid}")
    void updateStatus( Integer moringStatus,String openid);
    @Update("update  cron set nightStatus=#{nightStatus} where openid=#{openid}")
    void updateNightStatus(String openid, Integer nightStatus);

    @Select("select *  from cron  where  openid=#{openid}")
    List<Cron> selectCronByOpenid(String openid);

    @Update("update  cron set moringStatus=#{moringStatus},nightStatus=#{nightStatus},cronmoring=#{cronmoring},cornnight=#{cornnight} where openid=#{openid}")
    void updateByTenp(TempData templateData);
}
